package sv.gob.mh.dgii.html.editor;

import java.text.DecimalFormat;

public class SiitNumberEditor extends SiitEditor {

    public SiitNumberEditor() {
        super("###,###,###,##0.00");
    }

    public SiitNumberEditor(String format) {
        super(format);
    }

    @Override
    public void setAsText(String value) {
        try {
            DecimalFormat df = new DecimalFormat(format);
            setValue(df.parse(value));
        } catch (Exception e) {
            setValue(null);
        }
    }

    @Override
    public String getAsText() {
        String ret = null;
        try {
            DecimalFormat df = new DecimalFormat(format);
            ret = df.format(getValue());
        } catch (Exception e) {
        }
        return ret;
    }
}
